package net.imagine.backend.mockrmi.remote.provider.mina.client;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.mina.core.service.IoHandlerAdapter;
import org.apache.mina.core.session.IoSession;

/**
 * Mina实现的客户端IO处理类
 * 
 * @author wuqh
 * @see IoHandlerAdapter
 * */
public class MinaClientIoHandler extends IoHandlerAdapter {
	private static final Log logger = LogFactory.getLog(MinaClientIoHandler.class);

	@Override
	public void exceptionCaught(IoSession session, Throwable cause) throws Exception {
		logger.error("client occurred an unexpected excpetion", cause);
		session.close(true);
	}

	@Override
	public void messageReceived(IoSession session, Object message) throws Exception {
		logger.debug("Client:message received");
	}

	@Override
	public void messageSent(IoSession session, Object message) throws Exception {
		logger.debug("Client:message sended");
	}

	@Override
	public void sessionClosed(IoSession session) throws Exception {
		logger.debug("Client:session closed");
	}

	@Override
	public void sessionOpened(IoSession session) throws Exception {
		logger.debug("Client:session opened");
	}

}
